package com.deekian.weixin.confirm;

import com.deekian.weixin.confirm.mould.WeixinAppInfo;

import java.util.HashMap;
import java.util.Map;

public class AccessTokenRequest {
    public static final String DEFAULT_GRANT_TYPE = "authorization_code";
    public String code;
    public String grantType;

    Map<String, String> toParam(WeixinAppInfo info) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("code", this.code);
        if (this.grantType == null || this.grantType.length() == 0) {
            params.put("grant_type", this.grantType);
        } else {
            params.put("grant_type", DEFAULT_GRANT_TYPE);
        }
        params.put("appid", info.appId);
        params.put("secret", info.secretKey);
        return params;
    }
}
